#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
void solve()
{
    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> customers(n);
    vector<pair<int, int>> stations(m);

    for (int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        customers[i] = {x + y, x - y};
    }

    for (int i = 0; i < m; ++i)
    {
        int x, y;
        cin >> x >> y;
        stations[i] = {x + y, x - y};
    }

    int minX = INT_MAX, maxX = INT_MIN;
    int minY = INT_MAX, maxY = INT_MIN;

    for (auto &c : customers)
    {
        minX = min(minX, c.first);
        maxX = max(maxX, c.first);
        minY = min(minY, c.second);
        maxY = max(maxY, c.second);
    }

    int minMaxDistance = INT_MAX;

    for (auto &s : stations)
    {
        int distX = max(abs(s.first - minX), abs(s.first - maxX));
        int distY = max(abs(s.second - minY), abs(s.second - maxY));
        int maxDist = max(distX, distY);
        minMaxDistance = min(minMaxDistance, maxDist);
    }

    cout << minMaxDistance << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
